{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "运行环境：jupyter notebook"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data=pd.read_csv('card_transdata.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.datasets import load_iris # iris数据集\n",
    "from sklearn.model_selection import train_test_split # 分割数据模块\n",
    "from sklearn.neighbors import KNeighborsClassifier # K最近邻(kNN，k-NearestNeighbor)分类算法\n",
    "import matplotlib.pyplot as plt #可视化模块\n",
    "import warnings \n",
    "warnings.filterwarnings('ignore')\n",
    "# ————————————————\n",
    "# 版权声明：本文为CSDN博主「yh_1021」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。\n",
    "# 原文链接：https://blog.csdn.net/yh_1021/article/details/82461388"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Max-Min标准化\n",
    "\n",
    "from sklearn import preprocessing \n",
    "minmax_scaler=preprocessing.MinMaxScaler()\n",
    "data_minmax_1=minmax_scaler.fit_transform(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "cols = data_minmax_1.shape[1]\n",
    "X = data_minmax_1[:, 0:cols - 1]\n",
    "y = data_minmax_1[:, cols - 1:cols]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "#划分固定的训练集和测试集\n",
    "from sklearn.model_selection import train_test_split \n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.01,random_state=123)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# （1）随机过采样\n",
    "\n",
    "from imblearn.over_sampling import RandomOverSampler\n",
    "ros = RandomOverSampler(random_state=0)\n",
    "X_oversampled, y_oversampled = ros.fit_resample(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# (2)SMOTE过采样：\n",
    "from imblearn.over_sampling import SMOTE\n",
    "smote = SMOTE(random_state=0)\n",
    "X_smotesampled, y_smotesampled = smote.fit_resample(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(990000, 7)\n",
      "(990000, 1)\n",
      "(10000, 7)\n",
      "(10000, 1)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "fraud\n",
       "0.0      903478\n",
       "1.0      903478\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#我们用这个固定的训练集去训练模型\n",
    "print(X_train.shape)\n",
    "print(y_train.shape)\n",
    "\n",
    "#测试集检验模型泛化能力\n",
    "print(X_test.shape)\n",
    "print(y_test.shape)\n",
    "y_oversampled.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "from sklearn.model_selection import cross_val_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "k is 1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 20013 (\\N{CJK UNIFIED IDEOGRAPH-4E2D}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 36817 (\\N{CJK UNIFIED IDEOGRAPH-8FD1}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 37051 (\\N{CJK UNIFIED IDEOGRAPH-90BB}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 25968 (\\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 30340 (\\N{CJK UNIFIED IDEOGRAPH-7684}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 20540 (\\N{CJK UNIFIED IDEOGRAPH-503C}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 20132 (\\N{CJK UNIFIED IDEOGRAPH-4EA4}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 21449 (\\N{CJK UNIFIED IDEOGRAPH-53C9}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 39564 (\\N{CJK UNIFIED IDEOGRAPH-9A8C}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 35777 (\\N{CJK UNIFIED IDEOGRAPH-8BC1}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 31934 (\\N{CJK UNIFIED IDEOGRAPH-7CBE}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 30830 (\\N{CJK UNIFIED IDEOGRAPH-786E}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n",
      "F:\\soft\\Anaconda3\\lib\\site-packages\\IPython\\core\\pylabtools.py:151: UserWarning: Glyph 24230 (\\N{CJK UNIFIED IDEOGRAPH-5EA6}) missing from current font.\n",
      "  fig.canvas.print_figure(bytes_io, **kw)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZUAAAEGCAYAAACtqQjWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAzm0lEQVR4nO3dd3xV9fnA8c+ThAQSSAIhYWQQRtibGES2A9GiCC5oraMKpYIVrVbrz1ptq0VqHVUrDrTaqjgQxUkRkCEgJMwEAoShhDDCDCv7+f1xD3qNCSSQm5t787xfr7xy8j3ne+/z9UqenO86oqoYY4wx1SHA2wEYY4zxH5ZUjDHGVBtLKsYYY6qNJRVjjDHVxpKKMcaYahPk7QC8qWnTppqYmOjtMIwxxqekpaXtV9Xo8s7V6aSSmJhIamqqt8MwxhifIiLfVnTOur+MMcZUG0sqxhhjqo0lFWOMMdXGkooxxphqY0nFGGNMtbGkYowxptpYUjHGGFNt6vQ6lbO150g+b33zLSH1AgkODCCkXgAhQQGEBAW6vtc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N8HzMLVzecP9jr93qf6v/d5OZ5zoqp7nX/0pcDL+Njn5PTTzwTeVNUPnGKf/ozKa5Ovf04AqnoY+AoYjoc+I0sqLiuBJBFpLSLBwBhgtpdjOiciEuYMMiIiYcAwIP30tXzGbOAm5/gm4CMvxnLOTv3DdozChz4nZxB4OrBRVZ90O+Wzn1FFbfLVz0lEokUk0jluAFwMZOKhz8hmfzmc6YFPA4HAq6r6qHcjOjci0gbX3QlAEPCWL7ZJRN4GhuDapnsv8CfgQ+BdIAH4DrhWVX1i8LuC9gzB1aWiwA7g16f6ums7ERkALAbWA6VO8QO4xiB89TOqqE1j8cHPSUS64xqID8R1I/Guqv5ZRKLwwGdkScUYY0y1se4vY4wx1caSijHGmGpjScUYY0y1saRijDGm2lhSMcYYU20sqRhzBiKS6L6rcG0lIv8WkWu8HYep24K8HYAxdYWIbAPcd77urKptqqu8gvccAvwd15qYU0qAp8orV1XbSNWcE0sqxlSBs6h0JvAW0A8IxbUf1CxV/b1zzTHgGWAEcBIYqap7gdmqOtnttZ52Dqur3D3Ov+DaeugN4FFV/bCc6ysqN+asWfeXMZUkIh1wJZRbgFxcq6uvB7oB14vIqf3jwoDlqtoDWASMq+E4p+LacfYWflgRbkyNsKRiTOVE49ob6QZVXeOUzVPVI6qaj6s7qpVTXgh84hynAYk1GOcfgUhV/bXadhnGCyypGFM5R3A9c6e/W1mB23EJP3QnF7n9QncvrwkrgT4i0qQG39OY79mYijGVU4jryXhznDGT2uoLYA7wqYgM83Ywpu6xOxVjKklVj+MafL8LiPByOBVS1fdwPe9jNtDAy+GYOsbuVIw5A1XdAXR1jg8D55VzzQi344Zux+8D73s8SNd73ex2/CrwqjOlOKQm3t8YsKRiTE1KFpEP3X5uWs3l5TkO/J+I3OxWtuc05cacE3ueijHGmGpjYyrGGGOqjSUVY4wx1caSijHGmGpjScUYY0y1saRijDGm2vw/eUVtfnfMiKoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "k_range=range(1,31)\n",
    "k_score=[]\n",
    "max=0\n",
    "index=0\n",
    "for i in k_range:\n",
    "    knn = KNeighborsClassifier(n_neighbors=i)\n",
    "    score=cross_val_score(knn,X_smotesampled, y_smotesampled,cv=5\n",
    "                         )\n",
    "    if score.mean() > max:\n",
    "        max = score.mean()\n",
    "        index = i\n",
    "\n",
    "    k_score.append(score.mean())\n",
    "\n",
    "print('k is %d' %index)\n",
    "plt.plot(k_range,k_score)\n",
    "plt.xlabel('knn中近邻数k的值')\n",
    "plt.ylabel('交叉验证精确度')\n",
    "plt.show()\n",
    "# ————————————————\n",
    "# 版权声明：本文为CSDN博主「yh_1021」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。\n",
    "# 原文链接：https://blog.csdn.net/yh_1021/article/details/82461388"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#************************************************************************************************\n",
    "#用平均方差(Mean squared error)判断模型好坏\n",
    "k_scores=[]\n",
    "for k in k_range:\n",
    "    knn = KNeighborsClassifier(n_neighbors=k)\n",
    "    loss = -cross_val_score(knn, X, y, cv=10, scoring='mean_squared_error')\n",
    "    k_scores.append(loss.mean())\n",
    "\n",
    "plt.plot(k_range, k_scores)\n",
    "plt.xlabel('Value of K for KNN')\n",
    "plt.ylabel('Cross-Validated MSE')\n",
    "plt.show()\n",
    "# ————————————————\n",
    "# 版权声明：本文为CSDN博主「yh_1021」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。\n",
    "# 原文链接：https://blog.csdn.net/yh_1021/article/details/82461388"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "model= KNeighborsClassifier(n_neighbors=1)\n",
    "start_time = time.time()\n",
    "\n",
    "print(\"time - {}\".format(time.time()-start_time))\n",
    "cv_scores_k.append(r2_score.mean())\n",
    "print(r2_score.mean())\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(k,cv_scores_k)\n",
    "plt.xlabel('k')\n",
    "plt.ylabel('f1')\t\t#通过图像选择最好的参数\n",
    "plt.show()\n",
    "print(max(cv_scores_k))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'algorithm': 'auto',\n",
       " 'leaf_size': 30,\n",
       " 'metric': 'minkowski',\n",
       " 'metric_params': None,\n",
       " 'n_jobs': None,\n",
       " 'n_neighbors': 3,\n",
       " 'p': 2,\n",
       " 'weights': 'uniform'}"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf_sk.get_params()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'algorithm': 'auto',\n",
       " 'leaf_size': 30,\n",
       " 'metric': 'minkowski',\n",
       " 'metric_params': None,\n",
       " 'n_jobs': None,\n",
       " 'n_neighbors': 3,\n",
       " 'p': 2,\n",
       " 'weights': 'uniform'}"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.get_params()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9862"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf_sk.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9862"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.score(X_test, y_test)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
